package com.loopy.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;

public class LoginCheckServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("LoginCheckServlet被调用");
        String password = request.getParameter("password");
        if("123456".equals(password)){
            String username = request.getParameter("username");
            HttpSession session = request.getSession();
            session.setAttribute("username",username);
            request.getRequestDispatcher("/manage/admin.jsp").forward(request,response);
        }else {
            request.getRequestDispatcher("/login.jsp").forward(request,response);
        }
    }
}
